package stack.tests;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.junit.Test;

import stack.programs.Stack;

public class StackTestProperty4a {
	//Properties a Stack implementation needs to have to be correct:
	// 1: LIFO 
	// 2.1: popping the Stack with pop() returns the element last added
	// 2.2: popping the Stack with pop() removes the element last added
	// 3.1: looking at the Stack with peek() returns the element last added
	// 3.2: looking at the Stack with peek() does not remove the element last added
	// 4.1: pushing onto the Stack with push(item) changes the top element into the item
	// 4.2: pushing onto the Stack with push(item) moves the old last pushed item down the stack one.
	// 5: size() must return the amount of elements in the Stack
	// 6: check() must make sure all internal invariants are still there:
	// 6.1: an empty stack has no first element
	// 6.2: a stack of size one has one element
	// 6.3: a stack larger than size one has more than one element
	// 7: isEmpty() is only true if the stack size is also 0
	
	@Test
	public void checkPush() {
		Stack<Integer> stack = StackTestUtility.getObjectOfClassToTest();
		int oldPushedObject = 1;
		stack.push(oldPushedObject);
		List<Integer> pushed = new ArrayList<Integer>();
		pushed.add(oldPushedObject);
		Iterator<Integer> stackIterator = stack.iterator();
		for(int i = 0; i < 1; i++) {
			Integer fromStack = stackIterator.next();
			assertTrue(fromStack.equals(pushed.get(i)));
		}
	}
}

